package cn.schoolwow.util.module.query.resource.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.net.URL;

public class CopyToFileFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        URL url = (URL) flowContext.checkData("url");
        String targetFilePath = (String) flowContext.checkData("targetFilePath");

        File targetFile = new File(targetFilePath);
        FileUtils.copyURLToFile(url, targetFile);
    }

    @Override
    public String name() {
        return "复制到指定文件";
    }
}
